#include <boost/test/unit_test.hpp>

#include <phalanx/type_traits/is_same.hpp.cu>

#include <phalanx/utility/pair.hpp.cu>
using namespace phalanx;

namespace ns_pair
{

BOOST_AUTO_TEST_CASE( _pair )
{
    pair< int, int > x( 0, 1 );
    BOOST_REQUIRE(( x.first == 0 ));
    BOOST_REQUIRE(( x.second == 1 ));

    pair< int, int > y( 2, 3 );
    BOOST_REQUIRE(( y.first == 2 ));
    BOOST_REQUIRE(( y.second == 3 ));
    y = x;
    BOOST_REQUIRE(( y.first == 0 ));
    BOOST_REQUIRE(( y.second == 1 ));

    BOOST_REQUIRE(( make_pair( 0, 1 ) == x ));
    BOOST_REQUIRE(( make_pair( 2, 3 ) != y ));

    BOOST_REQUIRE(( make_pair( 0, 0 ) < x ));
    BOOST_REQUIRE(( make_pair( 0, 0 ) <= x ));
    BOOST_REQUIRE(( make_pair( 0, 1 ) <= x ));

    BOOST_REQUIRE(( make_pair( -1, 2 ) < x ));
    BOOST_REQUIRE(( make_pair( -1, 2 ) <= x ));

    BOOST_REQUIRE(( make_pair( 0, 2 ) > x ));
    BOOST_REQUIRE(( make_pair( 0, 2 ) >= x ));
    BOOST_REQUIRE(( make_pair( 0, 1 ) >= x ));

    BOOST_REQUIRE(( make_pair( 1, 0 ) > x ));
    BOOST_REQUIRE(( make_pair( 1, 0 ) >= x ));
}

BOOST_AUTO_TEST_CASE( tuple_like_access )
{
    typedef pair< int, float > type;
    const type x( 1, 0.5f );

    BOOST_REQUIRE(( get< 0 >( x ) == 1 ));
    BOOST_REQUIRE(( get< 1 >( x ) == 0.5f ));

    BOOST_REQUIRE(( is_same< int, tuple_element< 0, type >::type >::value ));
    BOOST_REQUIRE(( is_same< float, tuple_element< 1, type >::type >::value ));

    BOOST_REQUIRE(( tuple_size< type >::value == 2 ));
}

} // namespace ns_pair

